* This file creates Figure 2.6 and Figure 2.7

* Open dataset of contributors to state political parties in 2010 cycle (provided by NIMSP)
use statepartycontributors.dta, clear

* Rename state variable to prepare for urging
ren standardizedstate statabbr

* Collapse data to create state-level totals of contributors and amounts
collapse (sum) amount number, by(statabbr)

* Merge in dataset documenting campaign finance laws in place in 2010
sort statabbr
merge statabbr using cflaws2010
drop if _m<3
drop _m

* Merge in a dataset exported from Catalist indicating amount of polarization in 
* each state
sort statabbr 
merge statabbr using statedonorideology

* Generate measures of per capita donors and amounts donated to parties
gen amountpercapita=amount/voters_total
gen numberpercapita=number/voters_total

* These commands will create Figures 2.6 and 2.7
mean amountpercapita, over(indlims l_ind_party)
parmest, saving(amountpercapita, replace)

mean numberpercapita, over(indlims l_ind_party)
parmest, saving(numberpercapita, replace)

gen polarization=0 if voters_iqrange<25
replace polarization=1 if voters_iqrange==25
replace polarization=2 if voters_iqrange>25

mean party_iqrange, over(polarization indlims)
parmest, saving(partydonorpolarization, replace)


use amountpercapita, clear
gen indicator=0
append using numberpercapita
recode indicator .=1

destring parm, gen(laws) ig(_subpop_)

label define indicator 0 "Amount per capita" 1 "Donors per capita"

twoway bar estimate laws if indicator==0, mcolor(black) xlabel(.5 " " 1 "No Limits" 2 "Limited to Cands" 3 "Limited to Cands/Parties   " 3.5 " ", labs(medsmall) notick alt) ytitle(" ") xtitle(" ") ylabel(0 .1 .2 .3 .4 .5 .6 .7 .8) scheme(s1mono) barw(.5) title("Amount per capita") saving(graph1.gph, replace) aspect(1)
twoway bar estimate laws if indicator==1, mcolor(black) xlabel(.5 " " 1 "No Limits" 2 "Limited to Cands" 3 "Limited to Cands/Parties   " 3.5 " ", labs(medsmall) notick alt) ytitle(" ") xtitle(" ") ylabel(0 .0005 .001 .0015 .002) scheme(s1mono) barw(.5) title("Donors per capita") saving(graph2.gph, replace) aspect(1)

graph combine graph1.gph graph2.gph, graphr(c(white))
graph export fig_2_6.eps, replace


use partydonorpolarization, clear

gen temp=_n
recode temp 1=0 2=1 3=0 4=1 5=0 6=1, gen(limits)
recode temp 1/2=1 3/4=2 5/6=3, gen(polarization)

twoway scatter estimate polarization if limits==0, mcolor(gs12) || scatter estimate polarization if limits==1, mcolor(black) xlabel(.5 " " 1 "Low Polarization" 2 "Medium Polarization" 3 "High Polarization" 3.5 " ") xtitle("Polarization among Voters in State") ytitle("Polarizaton among Party Donors") legend(lab(1 "No Limits on Giving to Candidates") lab(2 "Limits on Giving to Candidates")) scheme(s1mono) ylabel(0 10 20 30 40 50)
graph export fig_2_7.eps, replace
 
